﻿using CommonDevelop.Operator;
using CommonEngine;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace WebAdmin.Handler
{
    [Authorize(Policy = AuthPolicy.PERMISSION)]     //API的权限验证
    public class BaseWebApiController : ControllerBase
    {
        private string _token;
        /// <summary>
        /// 授权Token
        /// </summary>
        public string Token
        {
            get
            {
                if (_token == null)
                    _token = this.Request.Headers["Authorization"];

                if (!_token.IsEmpty())
                    _token = _token.Replace("Bearer ", "");

                return _token;
            }
            set { _token = value; }
        }
    }
}
